import { Modal } from 'antd';
import { forwardRef, useImperativeHandle, useState } from 'react';
import type { PropsType } from './type.ts';

const Index = forwardRef((props: PropsType, ref) => {
  const { children, ...rest } = props;
  const [open, setOpen] = useState(false);
  useImperativeHandle(ref, () => ({
    show: () => {
      setOpen(true);
    },
    close: () => {
      setOpen(false);
    },
  }));
  return (
    // maskClosable={false}
    <Modal open={open} onCancel={() => setOpen(false)} {...rest}>
      {children}
    </Modal>
  );
});

export default Index;
